#!/bin/bash
set -e

psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" <<-EOSQL
    CREATE USER $PLANDEX_USER WITH PASSWORD '$PLANDEX_PASSWORD';
    CREATE DATABASE $PLANDEX_DB OWNER $PLANDEX_USER;
    GRANT ALL PRIVILEGES ON DATABASE $PLANDEX_DB TO $PLANDEX_USER;
EOSQL

